# -* -coding: utf-8 -*-
import random
import requests
import win32api
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
import time,json,threading
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
from datetime import datetime, time

def driver_init():
    try:
        options = webdriver.ChromeOptions()
        options.binary_location = r"C:\Chrome\Chrome.exe"
        options.add_argument('--disable-gpu') #谷歌文档提到需要加上这个属性来规避bug
        options.add_experimental_option('excludeSwitches', ['enable-automation'])
        options.add_experimental_option('useAutomationExtension', False)
        driver = webdriver.Chrome(r'C:\Chrome\Chromedriver.exe',options=options)
        driver.maximize_window()
        driver.get("http://www.cjzzc.com/wailian.html")
        time.sleep(random.randint(1, 3))
        driver.implicitly_wait(45)
        driver.find_element_by_xpath("//*[@id=\"url\"]").send_keys('www.yujianlong.com')
        time.sleep(1)
        driver.find_elements_by_class_name("button-royal")[0].click()
        time.sleep(3600)
        driver.quit()
        return 1
    except Exception as e:
        print(e)

def driver_init1():
    try:
        options = webdriver.ChromeOptions()
        options.binary_location = r"C:\Chrome\Chrome.exe"
        options.add_argument('--disable-gpu') #谷歌文档提到需要加上这个属性来规避bug
        options.add_experimental_option('excludeSwitches', ['enable-automation'])
        options.add_experimental_option('useAutomationExtension', False)
        driver = webdriver.Chrome(r'C:\Chrome\Chromedriver.exe',options=options)
        driver.maximize_window()
        driver.get("https://seo.dmeng.net")
        time.sleep(random.randint(1, 3))
        driver.implicitly_wait(45)
        driver.find_element_by_xpath("//*[@id=\"domain\"]").send_keys('www.yujianlong.com')
        time.sleep(1)
        driver.find_elements_by_class_name("btn-primary")[0].click()
        time.sleep(3600)
        driver.quit()
        return 1
    except Exception as e:
        print(e)   

def driver_init2():
    try:
        options = webdriver.ChromeOptions()
        options.binary_location = r"C:\Chrome\Chrome.exe"
        options.add_argument('--disable-gpu') #谷歌文档提到需要加上这个属性来规避bug
        options.add_experimental_option('excludeSwitches', ['enable-automation'])
        options.add_experimental_option('useAutomationExtension', False)
        driver = webdriver.Chrome(r'C:\Chrome\Chromedriver.exe',options=options)
        driver.maximize_window()
        driver.get("http://tool.lusongsong.com/seo/")
        time.sleep(random.randint(1, 3))
        driver.implicitly_wait(45)
        driver.find_element_by_xpath("//*[@id=\"dn\"]").send_keys('www.yujianlong.com')
        time.sleep(1)
        driver.find_element_by_xpath("//*[@id=\"linkbtn\"]").click()
        time.sleep(3600)
        driver.quit()
        return 1
    except Exception as e:
        print(e)   

def run_web():
    driver_init()
    driver_init1()
    # driver_init2()
    time.sleep(20000)
# while True:
#     run_web()
    # nhour = datetime.now().hour
    # nminute = datetime.now().minute
    # nsecond = datetime.now().second
    # if nhour==12 and nminute==0 and nsecond==0:
    #     driver_init2()
DAY_START = time(8, 30)
current_time = datetime.now().time()
print(current_time) 
